<template>
  <div v-loading="loading" class="app-container">
    <el-row>
      <!-- 树结构 -->
      <el-col :span="6" :xs="24">
        <div class="mainbox-left">
          <!-- <div class="box-card"> -->
          <AdminGroup :name="'管理员组'" :handle="true" @treeClick="treeClick" />
          <!-- </div> -->
        </div>
      </el-col>
      <el-col :span="18" :xs="24" style="padding-left: 0px">
        <div class="none2-border3 userlist mainbox">
          <div class="table-container">
            <span class="nameSpan">{{ orgInfo.admingroupName }}
              <span v-if="orgInfo.admingroupParentId === '-1'" class="describeSpan">
                该组为平台初始化生成的管理员组，组内成员可查看操作平台基础功能，如用户中心、认证中心、权限中心、系统配置，可查看平台全部组织机构的用户数据。</span>
            </span>
            <el-tabs v-model="activeName" @tab-click="handleClick">
              <el-tab-pane
                label="组成员"
                name="first"
              ><group-members
                v-if="activeName === 'first'"
                ref="memberRef"
                :group-id="groupId"
                :group-info="orgInfo"
              /></el-tab-pane>
              <el-tab-pane
                label="组权限"
                name="second"
              ><group-auth
                v-if="activeName === 'second'"
                ref="
                  authRef"
                :group-id="groupId"
                :group-info="orgInfo"
              /></el-tab-pane>
            </el-tabs>
          </div>
        </div>
      </el-col>
    </el-row>
  </div>
</template>

<script>
import AdminGroup from './components/adminGroup.vue'
import groupMembers from './components/groupMembers.vue'
import groupAuth from './components/groupAuth.vue'

export default {
  name: 'AdminManage',
  components: { AdminGroup, groupMembers, groupAuth },
  data() {
    return {
      activeName: '',
      groupId: '',
      orgInfo: {},
      loading: true
    }
  },
  mounted() {},
  methods: {
    treeClick(data) {
      this.orgInfo = data
      this.groupId = data.admingroupId
      this.loading = false
      this.activeName = 'first'
      this.$nextTick(() => {
        this.$refs.memberRef.getList()
      })
    },
    handleClick(tab, event) {
      if (this.activeName === 'first') {
        this.$nextTick(() => {
          this.$refs.memberRef.getList()
        })
      }
    }
  }
}
</script>
<style scoped lang="scss">
::v-deep .el-tabs__item {
  padding: 0 10px;
}

::v-deep .el-tabs__header {
  margin: 0;
}

.nameSpan {
  font-size: 20px;
  font-weight: 500;
  color: #131414;
  line-height: 28px;
  margin-bottom: 16px;
}

.describeSpan {
  margin-top: 2px;
  font-size: 14px;
  font-weight: 400;
  color: #131414;
  line-height: 24px;
  display: block;
}
::v-deep .el-tabs__item.is-top {
  font-weight: 400;
}
::v-deep .el-tabs__item.is-active {
  font-weight: 500;
}
</style>
